package customer.zspt.cn.customer.components.chat.chatQuiteVp;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.google.gson.Gson;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import java.util.List;

import customer.zspt.cn.customer.Adapter.QuiteOrderAdapter;
import customer.zspt.cn.customer.R;
import customer.zspt.cn.customer.constant.constant;
import customer.zspt.cn.customer.bean.QuiteOrderDao;
import customer.zspt.cn.customer.utils.SPUtils;

/**
 * Created by Administrator on 2018/7/18 0018.
 */

public class quiteOrderVpItem extends BaseVpItem implements AdapterView.OnItemClickListener{

    private View view;
    @ViewInject(R.id.vp_item_ls)
    private ListView vp_item_ls;
    Gson gson;
    private List<QuiteOrderDao.OrderDao> data;

    public quiteOrderVpItem(Activity activity) {
        super(activity);
        gson = new Gson();
    }
    @Override
    public View initView() {
        view = View.inflate(mActivity, R.layout.quite_vp_item,null);
        ViewUtils.inject(this,view);
        return view;
    }

    @Override
    public void initData() {
        String order = SPUtils.getString(mActivity, constant.GDATAPROP, "");
        QuiteOrderDao quiteOrderDao = gson.fromJson(order, QuiteOrderDao.class);
        data = quiteOrderDao.data;
        //数据适配器
        QuiteOrderAdapter adapter = new QuiteOrderAdapter(data,mActivity);
        vp_item_ls.setAdapter(adapter);
        vp_item_ls.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        if(mLintener!=null)
        {
            mLintener.getData(data.get(position));
        }
    }
}
